import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = `MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4A0BtHZN0YuiDCx1+O3z
b+HXRr11wKq6W3rEOGqwl96aFum8z79ulxGSrng2qtfqCNhNqcloRGgr41KQz2Tw
RDIrAalSvfG9sGOiAUIi5OuiN2l4KbKBomLBvQjCaX38c1fqoY7KOql9frlWUnqc
qEDsYMbbn9gYtRwkYQiF4jqaYX/YHtI70MOFm+KbXbsAvND9X12vfBekeBBf3qk5
tWTQo9KBX1nwGouihbqF+cNLpvOq5xcGHNeMHaX+IYBYtwhsRtZ4Q/VEWWoIVQsx
XWDRfaOuOyKRKoIqiUAuE0G67z82gcO0s2Lr+V9lsd5/OScWMOsaqCTt3hcOwBP9
xwIDAQAB`

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

